@@ -488,7 +488,7 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin):  | 
            ||
| 488 | 488 | 
                 | 
            
| 489 | 489 | 
                try:  | 
            
| 490 | 490 | 
                maintenance = MaintenancemanInfo.objects.get(brand_id=brand_id, user_id=self.user_id, status=True)  | 
            
| 491 | 
                - except SaleclerkInfo.DoesNotExist:  | 
            |
| 491 | 
                + except:  | 
            |
| 492 | 492 | 
                             maintenance = {}
               | 
            
| 493 | 493 | 
                 | 
            
| 494 | 494 | 
                         maintenance_info = maintenance.data if maintenance else {}
               | 
            
                @@ -0,0 +1,20 @@  | 
            ||
| 1 | 
                +# -*- coding: utf-8 -*-  | 
            |
| 2 | 
                +# Generated by Django 1.11.26 on 2020-06-02 08:50  | 
            |
| 3 | 
                +from __future__ import unicode_literals  | 
            |
| 4 | 
                +  | 
            |
| 5 | 
                +from django.db import migrations, models  | 
            |
| 6 | 
                +  | 
            |
| 7 | 
                +  | 
            |
| 8 | 
                +class Migration(migrations.Migration):  | 
            |
| 9 | 
                +  | 
            |
| 10 | 
                + dependencies = [  | 
            |
| 11 | 
                +        ('coupon', '0012_auto_20200413_1543'),
               | 
            |
| 12 | 
                + ]  | 
            |
| 13 | 
                +  | 
            |
| 14 | 
                + operations = [  | 
            |
| 15 | 
                + migrations.AddField(  | 
            |
| 16 | 
                + model_name='usercouponinfo',  | 
            |
| 17 | 
                + name='admin_name',  | 
            |
| 18 | 
                + field=models.CharField(blank=True, db_index=True, help_text='\u6838\u9500\u5458\u540d\u79f0', max_length=255, null=True, verbose_name='admin_name'),  | 
            |
| 19 | 
                + ),  | 
            |
| 20 | 
                + ]  | 
            
                @@ -79,6 +79,7 @@ class UserCouponInfo(BaseModelMixin):  | 
            ||
| 79 | 79 | 
                 | 
            
| 80 | 80 | 
                has_used = models.BooleanField(_(u'has_used'), default=False, help_text=u'是否已核销', db_index=True)  | 
            
| 81 | 81 | 
                admin_id = models.CharField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'核销员唯一标识', db_index=True)  | 
            
| 82 | 
                + admin_name = models.CharField(_(u'admin_name'), max_length=255, blank=True, null=True, help_text=u'核销员名称', db_index=True)  | 
            |
| 82 | 83 | 
                used_at = models.DateTimeField(_(u'used_at'), blank=True, null=True, help_text=u'维修券核销时间')  | 
            
| 83 | 84 | 
                is_coupon_admin_writeoff = models.BooleanField(_(u'is_coupon_admin_writeoff'), default=True, help_text=_(u'是否是管理员核销'), db_index=True)  | 
            
| 84 | 85 | 
                 | 
            
                @@ -169,6 +170,7 @@ class UserCouponInfo(BaseModelMixin):  | 
            ||
| 169 | 170 | 
                'has_expired': self.has_expired,  | 
            
| 170 | 171 | 
                'has_used': self.has_used,  | 
            
| 171 | 172 | 
                'admin_id': self.admin_id,  | 
            
| 173 | 
                + 'admin_name': self.admin_name,  | 
            |
| 172 | 174 | 
                'used_at': self.used_at,  | 
            
| 173 | 175 | 
                'coupon_from': self.activity_name if self.coupon_from == 'PROMOTION' else self.coupon_from,  | 
            
| 174 | 176 | 
                'clerk_name': self.clerk_name,  | 
            
                @@ -217,6 +217,21 @@ class RightInfo(BaseModelMixin):  | 
            ||
| 217 | 217 | 
                'left_num': 3,  | 
            
| 218 | 218 | 
                'left_tip': 3,  | 
            
| 219 | 219 | 
                }  | 
            
| 220 | 
                +  | 
            |
| 221 | 
                + def maintaindata(self, level):  | 
            |
| 222 | 
                + right_detail = ''  | 
            |
| 223 | 
                + if level == 1:  | 
            |
| 224 | 
                + right_detail = self.level1 if self.level1 else ''  | 
            |
| 225 | 
                + elif level == 2:  | 
            |
| 226 | 
                + right_detail = self.level2 if self.level2 else ''  | 
            |
| 227 | 
                + elif level == 3:  | 
            |
| 228 | 
                + right_detail = self.level3 if self.level3 else ''  | 
            |
| 229 | 
                + elif level == 4:  | 
            |
| 230 | 
                + right_detail = self.level4 if self.level4 else ''  | 
            |
| 231 | 
                + elif level == 5:  | 
            |
| 232 | 
                + right_detail = self.level5 if self.level5 else ''  | 
            |
| 233 | 
                +  | 
            |
| 234 | 
                + return right_detail  | 
            |
| 220 | 235 | 
                 | 
            
| 221 | 236 | 
                 | 
            
| 222 | 237 | 
                class ShotTypeInfo(BaseModelMixin):  | 
            
                @@ -131,17 +131,7 @@ def query_userinfo(request):  | 
            ||
| 131 | 131 | 
                coupons = UserCouponInfo.objects.filter(user_id=user.user_id)  | 
            
| 132 | 132 | 
                coupons = [coupon.data for coupon in coupons]  | 
            
| 133 | 133 | 
                 | 
            
| 134 | 
                - right_detail = ''  | 
            |
| 135 | 
                - if user.level == 1:  | 
            |
| 136 | 
                - right_detail = right.level1 if right.level1 else ''  | 
            |
| 137 | 
                - elif user.level == 2:  | 
            |
| 138 | 
                - right_detail = right.level2 if right.level2 else ''  | 
            |
| 139 | 
                - elif user.level == 3:  | 
            |
| 140 | 
                - right_detail = right.level3 if right.level3 else ''  | 
            |
| 141 | 
                - elif user.level == 4:  | 
            |
| 142 | 
                - right_detail = right.level4 if right.level4 else ''  | 
            |
| 143 | 
                - elif user.level == 5:  | 
            |
| 144 | 
                - right_detail = right.level5 if right.level5 else ''  | 
            |
| 134 | 
                + right_detail = right.maintaindata(level=user.level)  | 
            |
| 145 | 135 | 
                 | 
            
| 146 | 136 | 
                     return response(200, 'UserInfo Success', u'获取用户信息成功', data={
               | 
            
| 147 | 137 | 
                'coupons': coupons,  | 
            
                @@ -17,9 +17,10 @@ from account.models import UserInfo  | 
            ||
| 17 | 17 | 
                from coupon.models import UserCouponInfo  | 
            
| 18 | 18 | 
                from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo  | 
            
| 19 | 19 | 
                from logs.models import MchInfoEncryptLogInfo  | 
            
| 20 | 
                -from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, SaleclerkInfo  | 
            |
| 20 | 
                +from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, SaleclerkInfo, MaintenancemanInfo  | 
            |
| 21 | 21 | 
                from statistic.models import (DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo,  | 
            
| 22 | 22 | 
                SaleclerkSaleStatisticInfo, SaleStatisticInfo)  | 
            
| 23 | 
                +from member.models import RightInfo  | 
            |
| 23 | 24 | 
                from utils.error.errno_utils import (CouponStatusCode, ProductBrandStatusCode, ProductDistributorStatusCode,  | 
            
| 24 | 25 | 
                ProductMachineStatusCode, ProductModelStatusCode, SaleclerkStatusCode)  | 
            
| 25 | 26 | 
                 | 
            
                @@ -429,6 +430,7 @@ def clerk_query_coupon(request):  | 
            ||
| 429 | 430 | 
                     brandID = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_PK)
               | 
            
| 430 | 431 | 
                     user_id = request.POST.get('user_id', '')
               | 
            
| 431 | 432 | 
                     user_coupon_id = request.POST.get('user_coupon_id', '')
               | 
            
| 433 | 
                +    is_maintenance = int(request.POST.get('is_maintenance', 0))
               | 
            |
| 432 | 434 | 
                 | 
            
| 433 | 435 | 
                try:  | 
            
| 434 | 436 | 
                user = UserInfo.objects.get(user_id=user_id, status=True)  | 
            
                @@ -449,17 +451,31 @@ def clerk_query_coupon(request):  | 
            ||
| 449 | 451 | 
                return response(ProductBrandStatusCode.BRAND_NOT_FOUND)  | 
            
| 450 | 452 | 
                 | 
            
| 451 | 453 | 
                try:  | 
            
| 452 | 
                - clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, unionid=user.unionid, status=True)  | 
            |
| 453 | 
                - except SaleclerkInfo.DoesNotExist:  | 
            |
| 454 | 
                - return response(SaleclerkStatusCode.CLERK_NOT_FOUND)  | 
            |
| 455 | 
                -  | 
            |
| 456 | 
                - try:  | 
            |
| 457 | 454 | 
                user_coupon = UserCouponInfo.objects.get(user_coupon_id=user_coupon_id)  | 
            
| 458 | 455 | 
                except UserCouponInfo.DoesNotExist:  | 
            
| 459 | 456 | 
                return response(CouponStatusCode.COUPON_NOT_FOUND)  | 
            
| 457 | 
                +  | 
            |
| 458 | 
                + right_detail = ''  | 
            |
| 459 | 
                + if is_maintenance:  | 
            |
| 460 | 
                + try:  | 
            |
| 461 | 
                + maintenance = MaintenancemanInfo.objects.get(brand_id=brand.brand_id, user_id=user.user_id, status=True)  | 
            |
| 462 | 
                +  | 
            |
| 463 | 
                + # 维修人工费  | 
            |
| 464 | 
                + right = RightInfo.objects.get(right_id='X457xEV8KVxHQiTvhA7Dtf')  | 
            |
| 465 | 
                + member = UserInfo.objects.get(user_id=user_coupon.user_id)  | 
            |
| 466 | 
                +  | 
            |
| 467 | 
                + right_detail = right.maintaindata(level=member.level)  | 
            |
| 468 | 
                + except:  | 
            |
| 469 | 
                + return response(400001, 'MaintenancemanInfo Not Found', u'维修员不存在')  | 
            |
| 470 | 
                + else:  | 
            |
| 471 | 
                + try:  | 
            |
| 472 | 
                + clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, clerk_phone=user.phone, status=True)  | 
            |
| 473 | 
                + except SaleclerkInfo.DoesNotExist:  | 
            |
| 474 | 
                + return response(SaleclerkStatusCode.CLERK_NOT_FOUND)  | 
            |
| 460 | 475 | 
                 | 
            
| 461 | 476 | 
                     return response(200, data={
               | 
            
| 462 | 
                - 'user_coupon': user_coupon.data  | 
            |
| 477 | 
                + 'user_coupon': user_coupon.data,  | 
            |
| 478 | 
                + 'right': right_detail  | 
            |
| 463 | 479 | 
                })  | 
            
| 464 | 480 | 
                 | 
            
| 465 | 481 | 
                 | 
            
                @@ -468,6 +484,7 @@ def clerk_writeoff_coupon(request):  | 
            ||
| 468 | 484 | 
                     brandID = request.POST.get('brand_id', settings.KODO_DEFAULT_BRAND_PK)
               | 
            
| 469 | 485 | 
                     user_id = request.POST.get('user_id', '')
               | 
            
| 470 | 486 | 
                     user_coupon_id = request.POST.get('user_coupon_id', '')
               | 
            
| 487 | 
                +    is_maintenance = int(request.POST.get('is_maintenance', 0))
               | 
            |
| 471 | 488 | 
                 | 
            
| 472 | 489 | 
                try:  | 
            
| 473 | 490 | 
                user = UserInfo.objects.get(user_id=user_id, status=True)  | 
            
                @@ -486,30 +503,39 @@ def clerk_writeoff_coupon(request):  | 
            ||
| 486 | 503 | 
                brand = BrandInfo.objects.get(brand_id=brandID)  | 
            
| 487 | 504 | 
                except BrandInfo.DoesNotExist:  | 
            
| 488 | 505 | 
                return response(ProductBrandStatusCode.BRAND_NOT_FOUND)  | 
            
| 489 | 
                -  | 
            |
| 490 | 
                - try:  | 
            |
| 491 | 
                - clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, unionid=user.unionid, status=True)  | 
            |
| 492 | 
                - except SaleclerkInfo.DoesNotExist:  | 
            |
| 493 | 
                - return response(SaleclerkStatusCode.CLERK_NOT_FOUND)  | 
            |
| 494 | 
                -  | 
            |
| 506 | 
                +  | 
            |
| 495 | 507 | 
                try:  | 
            
| 496 | 508 | 
                user_coupon = UserCouponInfo.objects.get(user_coupon_id=user_coupon_id)  | 
            
| 497 | 509 | 
                if user_coupon.has_used:  | 
            
| 498 | 510 | 
                return response(CouponStatusCode.COUPON_HAS_USED)  | 
            
| 499 | 
                - elif user_coupon.is_coupon_admin_writeoff:  | 
            |
| 511 | 
                + elif user_coupon.is_coupon_admin_writeoff and not is_maintenance:  | 
            |
| 500 | 512 | 
                return response(CouponStatusCode.COUPON_PERMISSION_DENIED)  | 
            
| 501 | 
                - elif not user_coupon.has_expired:  | 
            |
| 513 | 
                + elif user_coupon.has_expired:  | 
            |
| 514 | 
                + return response(CouponStatusCode.COUPON_EXPIRED)  | 
            |
| 515 | 
                + except UserCouponInfo.DoesNotExist:  | 
            |
| 516 | 
                + return response(CouponStatusCode.COUPON_NOT_FOUND)  | 
            |
| 517 | 
                +  | 
            |
| 518 | 
                + user_coupon.has_used = True  | 
            |
| 519 | 
                + user_coupon.used_at = tc.utc_datetime()  | 
            |
| 520 | 
                +  | 
            |
| 521 | 
                + if is_maintenance:  | 
            |
| 522 | 
                + try:  | 
            |
| 523 | 
                + maintenance = MaintenancemanInfo.objects.get(brand_id=brand.brand_id, user_id=user.user_id, status=True)  | 
            |
| 524 | 
                + user_coupon.admin_id = maintenance.maintenance_id  | 
            |
| 525 | 
                + user_coupon.admin_name = maintenance.maintenance_name  | 
            |
| 526 | 
                + user_coupon.save()  | 
            |
| 527 | 
                + except:  | 
            |
| 528 | 
                + return response(400001, 'MaintenancemanInfo Not Found', u'维修员不存在')  | 
            |
| 529 | 
                + else:  | 
            |
| 530 | 
                + try:  | 
            |
| 531 | 
                + clerk = SaleclerkInfo.objects.get(brand_id=brand.brand_id, unionid=user.unionid, status=True)  | 
            |
| 502 | 532 | 
                user_coupon.clerk_id = clerk.clerk_id  | 
            
| 503 | 533 | 
                user_coupon.clerk_name = clerk.clerk_name  | 
            
| 504 | 534 | 
                user_coupon.distributor_id = clerk.distributor_id  | 
            
| 505 | 535 | 
                user_coupon.distributor_name = clerk.distributor_name  | 
            
| 506 | 
                - user_coupon.has_used = True  | 
            |
| 507 | 
                - user_coupon.used_at = tc.utc_datetime()  | 
            |
| 508 | 536 | 
                user_coupon.save()  | 
            
| 509 | 
                - else:  | 
            |
| 510 | 
                - return response(CouponStatusCode.COUPON_EXPIRED)  | 
            |
| 511 | 
                - except UserCouponInfo.DoesNotExist:  | 
            |
| 512 | 
                - return response(CouponStatusCode.COUPON_NOT_FOUND)  | 
            |
| 537 | 
                + except SaleclerkInfo.DoesNotExist:  | 
            |
| 538 | 
                + return response(SaleclerkStatusCode.CLERK_NOT_FOUND)  | 
            |
| 513 | 539 | 
                 | 
            
| 514 | 540 | 
                return response(200, 'Write Off Coupon Success', u'劵核销成功')  | 
            
| 515 | 541 | 
                 |